package flc.ast.adapter;

import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.bean.ContactInfo;

public class ContactsAdapter extends StkProviderMultiAdapter<ContactInfo> {

    public ContactsAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(80));
        addItemProvider(new ContactsProvider());
    }

    private class ContactsProvider extends BaseItemProvider<ContactInfo> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_contacts;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ContactInfo bean) {
            if (!TextUtils.isEmpty(bean.getName())) {
                baseViewHolder.setText(R.id.tvContactsItemName, bean.getName());
            } else {
                baseViewHolder.setText(R.id.tvContactsItemName, R.string.not_have_name_text);
            }
            baseViewHolder.setText(R.id.tvContactsItemPhone, bean.getPhone());
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivContactsItemSel, R.drawable.ayxz);
            } else {
                baseViewHolder.setImageResource(R.id.ivContactsItemSel, R.drawable.awxz);
            }
        }
    }


}
